package model;

import java.io.Serializable;

public class VoteResult implements Serializable, Comparable<VoteResult> {
	private String CandidateName;
	private int numberOfVotes;

	public VoteResult() {

	}

	public String getCandidateName() {
		return CandidateName;
	}

	public void setCandidateName(String candidateName) {
		CandidateName = candidateName;
	}

	public int getNumberOfVotes() {
		return numberOfVotes;
	}

	public void setNumberOfVotes(int numberOfVotes) {
		this.numberOfVotes = numberOfVotes;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((CandidateName == null) ? 0 : CandidateName.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		VoteResult other = (VoteResult) obj;
		if (CandidateName == null) {
			if (other.CandidateName != null)
				return false;
		} else if (!CandidateName.equals(other.CandidateName))
			return false;
		return true;
	}

	@Override
	public int compareTo(VoteResult other) {
		if (this.numberOfVotes > other.getNumberOfVotes())
			return -1;
		else if (this.numberOfVotes < other.getNumberOfVotes())
			return 1;
		else
			return 0;
	}

}
